<?php

/**
 * Jobboard form.
 *
 * @package    emc
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class JobboardForm extends BaseJobboardForm
{
  public function configure()
  {
  	$this->setWidgets(array(
			'name'					=>		new sfWidgetFormInput(),
			'alias'					=>		new sfWidgetFormInput(),
			'generator_name'		=>		new sfWidgetFormInput(),
			'address'				=>		new sfWidgetFormInput(),
			'currency_id'			=>		new sfWidgetFormSelect(array('choices' => $this->getCurrencyList())),
			'is_active'				=>		new sfWidgetFormInputCheckbox(),	
		));
				
		$this->widgetSchema->setNameFormat('jobboard[%s]');
		$this->widgetSchema->setLabels(array(
			'name'					=>		'Tên',
			'alias'					=>		'Viết tắt',
			'generator_name'		=>		'Tên Generator',
			'address'				=>		'Địa chỉ',
			'currency_id'			=>		'Tiền tệ',
			'is_active'				=>		'Khả dụng',
		));
  }


  private function getCurrencyList()
  {
  	$q = Doctrine_Query::create()
  			->from('Currency c')
  			->select('c.id, c.code');
  	$results = $q->fetchArray();
  	$currency = array();
  	foreach ($results as $result)
  		$currency[$result['id']] = $result['code'];
  	return $currency;
  }
}
